void setup ()
{
  pinMode(9,OUTPUT);
  Serial.begin(9600);
}
 
void loop()
{
 
  analogReadResolution(10);
  int ax = analogRead(A0);
   int temperature = convert_adc2temperature(ax,593,335,10,60); //更新后的数据
 
  int temp = (temperature - 40)*30;   // 放大温度变化
  if( temp >= 0 && temp <= 255){
    analogWrite(9,255 - (temperature - 40 + temp));
  }
  

  Serial.println(temp);
  
  
  
  
 
}

 int convert_adc2temperature(
    int ax,
    int a0, int a1,
    int temp0, int temp1)
{
    int tempx;
   tempx = temp0+(ax-a0)*(temp1-temp0)/(a1-a0);
   return tempx;
}



